var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("BoxItem"),
    s = cc._decorator,
    c = s.ccclass,
    p = s.property,
    l =
        (s.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.labDetail = null;
                e.lay = [];
                e.list = {};
                e.tag = "";
                return e;
            }
            e.prototype.onLoad = function () {};
            e.prototype.onDestroy = function () {
                for (var t in this.list) {
                    this.list[t].active = !0;
                    QLooperNode.putNode(this.list[t]);
                }
                this.list = {};
            };
            e.prototype.init = function (t, e, o) {
                var a = o.desc;
                this.labDetail.string = a ? CacheDataManager.getLang(a) + "" : "";
                var i = t.split("|");
                i.length <= 1 ? this.setRuleDataItem1(i, o) : this.setRuleDataItem2(i, o);
            };
            e.prototype.setRuleDataItem1 = function (t, e) {
                var o = t[0],
                    a = CacheDataManager.getCostumeup()[o];
                this.setBoxItem(this.lay[0], 0, 0, a);
                for (var i = ParseTool.getSplit(e.up_quality, "|"), n = 0; n < 2; n++)
                    this.setTypeBoxItem(this.lay[1], 1, n, i[n]);
                this.setBoxItem(this.lay[2], 2, 0, e);
            };
            e.prototype.setRuleDataItem2 = function (t, e) {
                var o = t[0],
                    a = CacheDataManager.getCostumeup(),
                    i = a[o];
                this.setBoxItem(this.lay[0], 0, 0, i);
                var n = a[t[1]],
                    r = a[t[2]];
                this.setBoxItem(this.lay[1], 1, 0, n);
                this.setBoxItem(this.lay[1], 1, 1, r);
                this.setBoxItem(this.lay[2], 2, 0, e);
            };
            e.prototype.setBoxItem = function (t, e, o, a) {
                var i = e + "_" + o,
                    n = this.list[i] || QLooperNode.getNode(QLooperNode.tag_boxItem);
                n.setPosition(cc.Vec2.ZERO);
                n.parent = t;
                this.list[i] = n;
                a ? this.viewItem(n, a) : (n.active = !1);
            };
            e.prototype.setTypeBoxItem = function (t, e, o, a) {
                var i = e + "_" + o,
                    n = this.list[i] || QLooperNode.getNode(QLooperNode.tag_boxItem);
                n.setPosition(cc.Vec2.ZERO);
                n.parent = t;
                this.list[i] = n;
                a ? this.setTypeData(n, parseInt(a + "")) : (n.active = !1);
            };
            e.prototype.viewItem = function (t, e) {
                t.active = !0;
                var o = t.getComponent(r.default);
                if (o) {
                    var a = CacheDataManager.getCostume()[e.costume_id];
                    o.tag = this.tag;
                    o.nodeKindItem.setTypeKind(a.type, e.quality);
                    o.typeIndex = a.type;
                    o.levelLab.string = "lv:1";
                    o.resetView();
                    SpriteView.setTaskSprite(o.iconSprite, CacheDataManager.getEquipCostumeUpToIcon(e));
                    o.setQualityData(e.quality);
                }
            };
            e.prototype.setTypeData = function (t, e) {
                t.active = !0;
                var o = t.getComponent(r.default);
                if (o) {
                    o.tag = this.tag;
                    o.nodeKindItem.setTypeKind(1, e);
                    o.typeIndex = 1;
                    o.levelLab.string = "lv:1";
                    o.resetView();
                    SpriteView.setTypeIcon(1, o.iconSprite);
                    o.setQualityData(e);
                }
            };
            n([p(cc.Label)], e.prototype, "labDetail", void 0);
            n([p([cc.Node])], e.prototype, "lay", void 0);
            return n([c], e);
        })(cc.Component));
o.default = l;
